<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
    <title>4_组件</title>

    <style>
        .box {
            width: 100px;
            height: 100px;
            text-align: center;
            line-height: 100px;
            font-weight: bold;
            font-family: 'Courier New', Courier, monospace;
            border-radius: 50%;
            background: #bfa;
        }

        .ellipse {
            width: 100px;
            height: 150px;
            border-radius: 50%;
            text-align: center;
            line-height: 150px;
            font-weight: bold;
            background: #fab;
        }
    </style>
</head>

<body>

    <div id="main"></div>

    <!-- 引入react核心库 -->
    <script src="./js/react.development.js"></script>
    <!-- 引入react-dom，用于支持react操作DOM -->
    <script src="./js/react-dom.development.js"></script>
    <!-- 引入babel，用于将jsx转为js -->
    <script src="./js/babel.min.js"></script>

    <script type="text/babel">
        //1. 函数式组件
        function Box() {
            return <div className="box">BOX</div>
        }

        ReactDOM.render(<Box />, document.getElementById('main'))

        //2. 类式组件
        class Ellipse extends React.Component {
            render() {
                return <div className="ellipse">ELLIPSE</div>
            }
        }

        ReactDOM.render(<Ellipse />, document.getElementById('main'))
    </script>
</body>

</html>